package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo6 {
    public static void main(String[] args) {
        try {
            Connection connection=DBUtil.getConnection();
            Statement statement=connection.createStatement();
            String sql="select t.name,t.gender,c.name,c.floor from teacher t join class  c on t.id=c.teacher_id where t.name='王克晶'";
            ResultSet resultSet=statement.executeQuery(sql);
            while(resultSet.next()){
                String Tname=resultSet.getString("t.name");
                String TGender=resultSet.getString("t.gender");
                String Cname=resultSet.getString("c.name");
                int floor=resultSet.getInt("c.floor");
                System.out.println(Tname+" "+TGender+" "+Cname+" "+floor);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
